/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
 * Description: all-reduce fusion header file
 * Author: lilianlin
 * Create: 2019-12-8
 */

#ifndef HVD_ALL_REDUCE_FUSION_H
#define HVD_ALL_REDUCE_FUSION_H

#include "hccl/base.h"
#include <hccl/hccl_types.h>
#include "common/optimizer/graph_optimizer.h"
#include "common/optimizer/graph_optimizer_types.h"
#include "graph/compute_graph.h"
#include "op_fusion_base_pub.h"

namespace hccl {
const float HVD_GRADIENT_SEGMENT_INDEX_RATIO = 0.67;

class HvdAllReduceFusion : public OpFusionBase {
public:
    HvdAllReduceFusion();
    ~HvdAllReduceFusion() override;
    HcclResult Run(ge::ComputeGraph& graph) override;
private:
    HcclResult GetFusionOps(ge::ComputeGraph& graph, std::vector<ge::NodePtr>& fusionOps);
    HcclResult GetSplitStrategy(ge::ComputeGraph& graph, std::vector<ge::NodePtr>& fusionOps,
        std::vector<u32>& segmentIndex);
};
}
#endif
